FROM centos:latest

RUN yum install -y gcc gcc-c++ zlib* automake autoconf libtool make expat-devel pcre-devel wget

RUN mkdir -p /root/src

WORKDIR /root/src
RUN wget http://www-us.apache.org/dist//apr/apr-1.6.3.tar.gz \
    && tar xvf apr-1.6.3.tar.gz \
	&& rm -f apr-1.6.3.tar.gz
WORKDIR /root/src/apr-1.6.3
RUN ./configure --prefix=/root/apr && make && make install

WORKDIR /root/src
RUN wget http://www-eu.apache.org/dist//apr/apr-util-1.6.1.tar.gz \
    && tar xvf apr-util-1.6.1.tar.gz \
	&& rm -f apr-util-1.6.1.tar.gz
WORKDIR /root/src/apr-util-1.6.1
RUN ./configure --prefix=/root/apr-util -with-apr=/root/apr/bin/apr-1-config && make && make install

WORKDIR /root/src
RUN wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz \
	&& tar xvf openssl-1.1.0h.tar.gz \
	&& rm -f openssl-1.1.0h.tar.gz
WORKDIR /root/src/openssl-1.1.0h
RUN ./config --prefix=/root/openssl -fPIC shared && make && make install

WORKDIR /root/src
RUN wget http://www-eu.apache.org/dist//httpd/httpd-2.4.33.tar.gz \
	&& tar xvf httpd-2.4.33.tar.gz \
	&& rm -f httpd-2.4.33.tar.gz
WORKDIR /root/src/httpd-2.4.33
RUN env CFLAGS="-Wall -DBIG_SECURITY_HOLE" ./configure --prefix=/root/httpd --with-apr=/root/apr --with-apr-util=/root/apr-util --with-ssl=/root/openssl --enable-ssl && make && make install

RUN ln -s /root/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
RUN ln -s /root/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

EXPOSE 443
VOLUME ["/root/httpd/logs"]
ENTRYPOINT ["/root/httpd/bin/httpd"]
CMD ["-D", "FOREGROUND"]

#docker run --rm -p 443:443 -d \
#    -v /root/work/docker-images/httpd/httpd.conf:/root/httpd/conf/httpd.conf \
#    -v /root/work/docker-images/httpd/httpd-ssl.conf:/root/httpd/conf/extra/httpd-ssl.conf \
#    -v /etc/letsencrypt/live/zoro.site/cert.pem:/root/httpd/conf/zoro.site.cert.pem \
#    -v /etc/letsencrypt/live/zoro.site/privkey.pem:/root/httpd/conf/zoro.site.privkey.pem \
#    -v /etc/letsencrypt/live/zoro.site/chain.pem:/root/httpd/conf/zoro.site.chain.pem \
#    -v /etc/letsencrypt/live/etourly.com/cert.pem:/root/httpd/conf/etourly.com.cert.pem \
#    -v /etc/letsencrypt/live/etourly.com/privkey.pem:/root/httpd/conf/etourly.com.privkey.pem \
#    -v /etc/letsencrypt/live/etourly.com/chain.pem:/root/httpd/conf/etourly.com.chain.pem \
#    -v /etc/letsencrypt/live/www.etourly.com/cert.pem:/root/httpd/conf/www.etourly.com.cert.pem \
#    -v /etc/letsencrypt/live/www.etourly.com/privkey.pem:/root/httpd/conf/www.etourly.com.privkey.pem \
#    -v /etc/letsencrypt/live/www.etourly.com/chain.pem:/root/httpd/conf/www.etourly.com.chain.pem \
#    httpd
